package enums;

import exception.*;

/**
 * @author wb_zhulinzhong
 * @date 2021-04-14 16:49:42
 */
public enum MessageTypeEnum {

    LOGIN(0, "登陆信息"),
    TEXT(1, "文本类型信息"),
    PICTURE(2, "图片类型信息"),
    BINARY(9, "二进制文件信息"),

    ;


    private Integer code;

    private String name;

    MessageTypeEnum(Integer code, String name) {
        this.code = code;
        this.name = name;
    }

    public Integer getCode() {
        return code;
    }

    public String getName() {
        return name;
    }

    public static MessageTypeEnum getMessageTypeEnum(Integer code){
        for (MessageTypeEnum typeEnum : MessageTypeEnum.values()) {
            if(typeEnum.getCode().equals(code)){
                return typeEnum;
            }
        }
        throw new BizException("错误的消息类型代码");
    }
}
